package com.example.gokchinesefoodmapmcdev.entity.page;

import java.util.List;

public class PageBean<T> {
    /**
     * 当前页数
     */
    private Integer currentPage = 1;

    /**
     * 一页显示的数据量
     */
    private Integer pageSize = 5;

    /**
     * 数据总数
     */
    private Integer totalNum;

    /**
     * 总页数
     */
    private Integer totalPage;

    /**
     * 分页结果
     */
    private List<T> rows;

    /**
     * 是否有下一页
     */
    private Integer isMore;

    /**
     * 开始索引
     */
    private Integer startIndex;

    public PageBean(){

    }

    public PageBean(Integer currentPage, Integer pageSize, Integer totalNum){
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.totalNum = totalNum;
        this.totalPage = (this.totalNum + this.pageSize -1)/this.pageSize;
        this.startIndex = (this.currentPage -1)* this.pageSize;
        this.isMore = this.currentPage >= this.totalPage ? 0 : 1;
    }

    public Integer getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(Integer currentPage) {
        this.currentPage = currentPage;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getTotalNum() {
        return totalNum;
    }

    public void setTotalNum(Integer totalNum) {
        this.totalNum = totalNum;
    }

    public Integer getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(Integer totalPage) {
        this.totalPage = totalPage;
    }

    public List<T> getRows() {
        return rows;
    }

    public void setRows(List<T> rows) {
        this.rows = rows;
    }

    public Integer getIsMore() {
        return isMore;
    }

    public void setIsMore(Integer isMore) {
        this.isMore = isMore;
    }

    public Integer getStartIndex() {
        return startIndex;
    }

    public void setStartIndex(Integer startIndex) {
        this.startIndex = startIndex;
    }

    @Override
    public String toString() {
        return "PageBean{" +
                "currentPage=" + currentPage +
                ", pageSize=" + pageSize +
                ", totalNum=" + totalNum +
                ", totalPage=" + totalPage +
                ", rows=" + rows +
                ", isMore=" + isMore +
                ", startIndex=" + startIndex +
                '}';
    }
}
